home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 11RLC35 (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.8 KB  |  97 lines

  1. package com.sun.java.swing.plaf.metal;
  2.  
  3. import com.sun.java.swing.AbstractButton;
  4. import com.sun.java.swing.ButtonModel;
  5. import com.sun.java.swing.Icon;
  6. import com.sun.java.swing.JMenu;
  7. import com.sun.java.swing.JMenuItem;
  8. import com.sun.java.swing.plaf.UIResource;
  9. import java.awt.Component;
  10. import java.awt.Graphics;
  11. import java.io.Serializable;
  12.  
  13. class MetalIconFactory$RadioButtonMenuItemIcon implements Icon, UIResource, Serializable {
  14.    public void paintIcon(Component c, Graphics g, int x, int y) {
  15.       JMenuItem b = (JMenuItem)c;
  16.       ButtonModel model = ((AbstractButton)b).getModel();
  17.       boolean isSelected = model.isSelected();
  18.       boolean isEnabled = model.isEnabled();
  19.       boolean isPressed = model.isPressed();
  20.       boolean isArmed = model.isArmed();
  21.       g.translate(x + 4, y);
  22.       if (isEnabled) {
  23.          if (!isPressed && !isArmed) {
  24.             g.setColor(MetalLookAndFeel.getControlHighlight());
  25.             g.drawLine(3, 1, 8, 1);
  26.             g.drawLine(2, 9, 7, 9);
  27.             g.drawLine(1, 3, 1, 8);
  28.             g.drawLine(9, 2, 9, 7);
  29.             g.drawLine(2, 2, 2, 2);
  30.             g.drawLine(8, 8, 8, 8);
  31.             g.setColor(MetalLookAndFeel.getControlDarkShadow());
  32.             g.drawLine(2, 0, 6, 0);
  33.             g.drawLine(2, 8, 6, 8);
  34.             g.drawLine(0, 2, 0, 6);
  35.             g.drawLine(8, 2, 8, 6);
  36.             g.drawLine(1, 1, 1, 1);
  37.             g.drawLine(7, 1, 7, 1);
  38.             g.drawLine(1, 7, 1, 7);
  39.             g.drawLine(7, 7, 7, 7);
  40.          } else {
  41.             g.setColor(MetalLookAndFeel.getPrimaryControl());
  42.             g.drawLine(3, 1, 8, 1);
  43.             g.drawLine(2, 9, 7, 9);
  44.             g.drawLine(1, 3, 1, 8);
  45.             g.drawLine(9, 2, 9, 7);
  46.             g.drawLine(2, 2, 2, 2);
  47.             g.drawLine(8, 8, 8, 8);
  48.             g.setColor(MetalLookAndFeel.getControlInfo());
  49.             g.drawLine(2, 0, 6, 0);
  50.             g.drawLine(2, 8, 6, 8);
  51.             g.drawLine(0, 2, 0, 6);
  52.             g.drawLine(8, 2, 8, 6);
  53.             g.drawLine(1, 1, 1, 1);
  54.             g.drawLine(7, 1, 7, 1);
  55.             g.drawLine(1, 7, 1, 7);
  56.             g.drawLine(7, 7, 7, 7);
  57.          }
  58.       } else {
  59.          g.setColor(MetalLookAndFeel.getMenuDisabledForeground());
  60.          g.drawLine(2, 0, 6, 0);
  61.          g.drawLine(2, 8, 6, 8);
  62.          g.drawLine(0, 2, 0, 6);
  63.          g.drawLine(8, 2, 8, 6);
  64.          g.drawLine(1, 1, 1, 1);
  65.          g.drawLine(7, 1, 7, 1);
  66.          g.drawLine(1, 7, 1, 7);
  67.          g.drawLine(7, 7, 7, 7);
  68.       }
  69.  
  70.       if (isSelected) {
  71.          if (!isEnabled) {
  72.             g.setColor(MetalLookAndFeel.getMenuDisabledForeground());
  73.          } else if (!model.isArmed() && (!(c instanceof JMenu) || !model.isSelected())) {
  74.             g.setColor(((Component)b).getForeground());
  75.          } else {
  76.             g.setColor(MetalLookAndFeel.getMenuSelectedForeground());
  77.          }
  78.  
  79.          g.drawLine(3, 2, 5, 2);
  80.          g.drawLine(2, 3, 6, 3);
  81.          g.drawLine(2, 4, 6, 4);
  82.          g.drawLine(2, 5, 6, 5);
  83.          g.drawLine(3, 6, 5, 6);
  84.       }
  85.  
  86.       g.translate(-(x + 4), -y);
  87.    }
  88.  
  89.    public int getIconWidth() {
  90.       return MetalIconFactory.access$menuCheckIconSize().width;
  91.    }
  92.  
  93.    public int getIconHeight() {
  94.       return MetalIconFactory.access$menuCheckIconSize().height;
  95.    }
  96. }
  97.